package com.example.controller;

import com.example.common.Result;
import com.example.domain.Books;
import com.example.domain.Spend_list;
import com.example.service.Spend_listService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class Spend_listController {

    @Autowired
    private Spend_listService spend_listService;

    @GetMapping("/selectAllById/{userId}")
    public Result selectAllById(@PathVariable Long userId){
        List<Spend_list> spend_lists = spend_listService.selectallById(userId);
        return Result.success(spend_lists);
    }

    /*
    添加充值记录
     */
    public void rechargeRecord(Integer recharge, Long uId){
        spend_listService.rechargeRecord(recharge,uId);
    }

    /*
    添加购书记录
     */
    public void consumeBook(Books book, Long userId){
        spend_listService.consumeBook(book, userId);
    }
}
